const appletSession = function() {
	var result = new Object();

	/**创建applet_session*/
	result.create = function() {
		function S4() {
			return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
		}
		var result = (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
		if ((uni.getStorageInfoSync("applet_session") + "").length < 10) {
			uni.setStorageSync(uni.setStorageSync("applet_session", result));
		}
		return result;
	}

	result.get = function() {
		return uni.getStorageSync("applet_session");
	}

	result.isExist = function() {
		if ((appletSession().get() + "").length < 10) {
			return false;
		}
		return true;
	}

	return result;
}

const request = function(result) {
console.log(appletSession().get());
	if (!appletSession().isExist()) {
		//如果不存在'applet_session'则创建'applet_session'
		appletSession().create();
	}

	result.header = {
		"Cookie": "APPLET_SESSION=" + appletSession().get()
	};
	uni.request(result);
	return result;

}

export default {
	appletSession,
	request
}
